package com.yao_shop.controller;

import com.yao_shop.service.File_service;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import net.sf.json.JSONArray;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 查询图片得所有信息通过数据库种得url地址遍历图片
 * */
@RestController
public class selectimgurlController {
    @Autowired
    File_service service;
    @ResponseBody
    @ApiOperation(value = "查询图片信息",notes = "查询图片所有的信息并且通过图片地址遍历图片")
    @GetMapping(value="imgurl.do")
    public String selecturl(Map map) {
        HashMap ma = new HashMap();
        List<Map> aaaa = service.selecturl(map);
        System.out.println("图片的所有信息："+aaaa);
        ArrayList list = new ArrayList<>();
        for (int i = 0; i < aaaa.size(); i++) {
            Object show = aaaa.get(i);
            list.add(show);
        }
        JSONArray js = JSONArray.fromObject(list.toArray());
        return js.toString();
    }
}
